<template>
  <div id="app">
    <router-view />
  </div>
</template>

<script>

export default {
  components: {
  },
  data() {
    return {
      navigationHeight: 47,
      statusBarHeight: 0,
    };
  },

  created() {
    console.log('app-created')
    this.getAPPUerInfo()
    this.getAPPNavHeight()
    const token = 'M7xF4cZvGO%2Fa626fxj8HEY2oXOprqYkkh7SQ5bITMy2vQPf70qDenklAnAWSNKg8DFEuxCl2ZdPJhd5IEVg%2FEv4TX%2B%2BtZzY97VkQ7G5BPuCKBp37HK7t0lhYxd898kiCBvyoRZq%2BfOtmAjWwVxxmDAG06dyeLxxY3E3F4OW8zps%3D'
    this.$store.commit('setToken', token)
  },

  mounted() {
  },

  methods: {
    getAPPNavHeight () {
      console.log('--appNavigation--', window)
      if (window.androidJSBridge) {
        const result = JSON.parse(window.androidJSBridge.appNavigation())
        this.navigationHeight = Number(result.navigationHeight)
        this.statusBarHeight = Number(result.statusBarHeight)
        document.documentElement.style.setProperty('--navHeight', this.navigationHeight + 'px')
        this.$store.commit('setNavHeight', this.navigationHeight)
        this.$store.commit('setStatusHeight', this.statusBarHeight)
        console.log('android1', result)
      } else if (window.webkit) {
        console.log('ios-appNavigation')
        window.appNavigation = this.onAppNavigation
        window.webkit.messageHandlers.appNavigation.postMessage({})
      }
    },
    getAPPUerInfo () {
      console.log('getAPPUerInfo', window)
      console.log('androidJSBridge', window.androidJSBridge)
      console.log('webkit', window.webkit)
      if (window.androidJSBridge) {
        const result = JSON.parse(window.androidJSBridge.appUserInfo())
        this.$store.commit('setToken', result.token)
        console.log('android-appUserInfo', result)
      } else if (window.webkit) {
        window.appUserInfo = this.onAppUserInfo
        window.webkit.messageHandlers.appUserInfo.postMessage({})
      }
    },

    onAppNavigation (result) {
      console.log('ios--appNavigation', result)
      this.navigationHeight = Number(result.navigationHeight)
      this.statusBarHeight = Number(result.statusBarHeight)
      document.documentElement.style.setProperty('--navHeight', this.navigationHeight + 'px')
      this.$store.commit('setNavHeight', this.navigationHeight)
      this.$store.commit('setStatusHeight', this.statusBarHeight)
    },

    onAppUserInfo (result) {
      console.log('ios-appUserInfo', result)
      this.$store.commit('setToken', result.token)
    },

  }
};
</script>

<style>
html, body, div, span, applet, object, iframe,
h1, h2, h3, h4, h5, h6, p, blockquote, pre,
a, abbr, acronym, address, big, cite, code,
del, dfn, em, img, ins, kbd, q, s, samp,
small, strike, strong, sub, sup, tt, var,
b, u, i, center,
dl, dt, dd, ol, ul, li,
fieldset, form, label, legend,
table, caption, tbody, tfoot, thead, tr, th, td,
article, aside, canvas, details, embed, 
figure, figcaption, footer, header, hgroup, 
menu, nav, output, ruby, section, summary,
time, mark, audio, video {
	margin: 0;
	padding: 0;
	border: 0;
}
body {
  font-size: 16px;
  color: #131419;
  background-color: #F6F6F6;
  -webkit-font-smoothing: antialiased;
  padding-bottom: constant(safe-area-inset-bottom);
  padding-bottom: env(safe-area-inset-bottom);
}
*{
  box-sizing: border-box;
  -webkit-touch-callout: none;
  font-family: "PingFang SC", "Hiragino Sans GB", "Heiti SC", "Arial", "Microsoft YaHei", "WenQuanYi Micro Hei";
  /* // -webkit-user-select: none;
  // -moz-user-select:none;
  // -ms-user-select:none;
  // user-select:none; */
}
/**
 * 适配 iphone 底部安全区
 */
/* @supports (bottom: env(safe-area-inset-bottom)){
  body {
    padding-bottom: constant(safe-area-inset-bottom);
    padding-bottom: env(safe-area-inset-bottom);
  }
} */
@import "./assets/css/color.css";
@import "./assets/css/flex.css";
@import "./assets/css/font.css";
@import "./assets/css/img.css";
@import "./assets/css/margin.css";
@import "./assets/css/padding.css";
@import "./assets/css/background.css";
@import "./assets/css/border.css";
@import "./assets/css/width.css";
@import "./assets/css/height.css";
@import "./assets/css/mixin.css";

#nprogress .bar {
  background: #D1FB71 !important;
}

/* .van-picker__columns .van-picker-column__item--selected { */
/* .van-picker__columns .van-picker-column__item {
  color: #D1FB71;
} */
/* .van-picker .van-picker__confirm {
  color: #131419;
} */
</style>
